home *** CD-ROM | disk | FTP | other *** search
Lisp/Scheme | 1988-04-07 | 1.6 KB | 49 lines | [TEXT/ttxt] |
- ;; Larry Mulcahy 1988
- ;; save
-
- (provide 'save)
- (require 'grind)
- (require 'io)
- (require 'sequence)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ascii-save
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; this function may not be named "save" because that is the name of the
- ; function to save a workspace.
-
- (defun ascii-save (x &key file directory verbose)
- (let*
- ((filename (come-up-with-a-filename x file))
- (prefixed-filename (if directory
- (concatenate 'string directory filename)
- filename))
- (f (open prefixed-filename :direction :output)))
- (if verbose (format t "Saving to ~A...." prefixed-filename))
- (if (atom x)
- (pprint (expr-to-make x) f)
- (flet
- ((maker-printer (x) (pprint (expr-to-make x) f)
- (terpri f)))
- (mapcar #'maker-printer x)))
- (close f)
- (if verbose (format t "done.~%"))
- filename))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; come-up-with-a-filename
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun come-up-with-a-filename (x file)
- (let ((name (or file
- (if (atom x)
- (string-downcase (symbol-name x))
- (ask :prompt "What is the file name? "
- :type 'string)))))
- (if (filename-extension-present-p name)
- name
- (concatenate 'string name *lisp-extension*))))
-
- (defun filename-extension-present-p (s) (position #\. s))
-